import http from "@/api";
import { ResPage } from "@/api/interface";
import {
  CreateCommodityCategoryParam,
  CreateCommodityParam,
  DeleteCommodityCategoryParam,
  DeleteCommodityParam,
  EditCommodityCategoryParam,
  EditCommodityParam,
  HxCommodity,
  HxCommodityCategory,
  QueryCommodityCategoryListParam,
  QueryCommodityCategoryPageListParam,
  QueryCommodityListParam,
  QueryCommodityPageListParam
} from "@/api/interface/commodity";

const apiName = "Commodity";

/** 创建商品 */
export const createCommodity = (param: CreateCommodityParam) => {
  return http.post<string>(`${apiName}/CreateCommodity`, param);
};

/** 创建商品类型 */
export const createCommodityCategory = (param: CreateCommodityCategoryParam) => {
  return http.post<string>(`${apiName}/CreateCommodityCategory`, param);
};

/** 查询所有商品列表（下拉选项用） */
export const queryCommodityList = (param: QueryCommodityListParam) => {
  return http.post<HxCommodity[]>(`${apiName}/QueryCommodityList`, param);
};

/** 查询所有商品分类（下拉选项用） */
export const queryCommodityPageList = (param: QueryCommodityPageListParam) => {
  return http.post<ResPage<HxCommodity>>(`${apiName}/QueryCommodityPageList`, param);
};

/** 查询商品列表分页接口 */
export const queryCommodityCategoryList = (param: QueryCommodityCategoryListParam) => {
  return http.post<HxCommodityCategory[]>(`${apiName}/QueryCommodityCategoryList`, param);
};

/** 查询商品分类分页接口 */
export const queryCommodityCategoryPageList = (param: QueryCommodityCategoryPageListParam) => {
  return http.post<ResPage<HxCommodity>>(`${apiName}/QueryCommodityCategoryPageList`, param);
};

/** 修改商品信息 */
export const editCommodity = (param: EditCommodityParam) => {
  return http.post<string>(`${apiName}/EditCommodity`, param);
};

/** 修改商品分类信息 */
export const editCommodityCategory = (param: EditCommodityCategoryParam) => {
  return http.post<string>(`${apiName}/EditCommodityCategory`, param);
};

/** 删除商品 */
export const deleteCommodity = (param: DeleteCommodityParam) => {
  return http.post<string>(`${apiName}/DeleteCommodity`, param);
};

/** 删除商品分类 */
export const deleteCommodityCategory = (param: DeleteCommodityCategoryParam) => {
  return http.post<string>(`${apiName}/DeleteCommodityCategory`, param);
};
